use "dataset_other_baton_rouge", clear

*******************************************************************************
* Share Black
*******************************************************************************

foreach year in 2010 2018 2020 {

	preserve
	
	keep if year == `year'

	su pctnhblack
	gen x = (pctnhblack - r(min)) / (r(max) - r(min))
	reg pctyes x [aw=totalvotes], robust
	local b = string(_b[x], "%20.02fc")
	local se = string(_se[x], "%20.02fc")
	
	#delimit;

	gr tw
		(sc pctyes pctnhblack [aw=totalvotes],
			msym(Oh) msize(tiny) col(gray))
		(lpoly pctyes pctnhblack [aw=totalvotes],
			col(black) lwid(thick))
		,
			plotregion(style(none))
			ylab(, angle(horiz))
			xtitle("")
			ytitle("")
			yline(0.5, lpat(dash))
			title(`year')
			name(g`year', replace)
			subtitle({&beta} = `b' (`se'))
			legend(off)
			;

	#delimit cr
	
	gr close
	
	restore

}

gr combine g2010 g2018 g2020, title("Baton Rouge, Louisiana") cols(3) ///
	ycommon b1title("Share Black") l1title("Share Yes Vote") imargin(zero)			

gr export "_output/figure A25 a.pdf", replace

*******************************************************************************
* Distance to Shooting
*******************************************************************************

foreach year in 2010 2018 2020 {

	preserve
	
	keep if year == `year'

	su distance
	gen x = (distance - r(min)) / (r(max) - r(min))
	reg pctyes x [aw=totalvotes], robust
	local b = string(_b[x], "%20.02fc")
	local se = string(_se[x], "%20.02fc")

	#delimit;

	gr tw
		(sc pctyes distance [aw=totalvotes], 
			msym(Oh) msize(tiny) col(gray))
		(lpoly pctyes distance [aw=totalvotes], 
			col(black) lwid(thick))
		,
			legend(off)
			plotregion(style(none))
			ylab(, angle(horiz))
			xtitle("")
			ytitle("")
			yline(0.5, lpat(dash))
			xscale(reverse)
			title(`year')
			name(g`year', replace)
			subtitle({&beta} = `b' (`se'))
			;

	#delimit cr
	
	gr close
	
	restore
	
}

gr combine g2010 g2018 g2020, title("Baton Rouge, Louisiana") cols(3) ///
	ycommon b1title("Distance to Shooting") l1title("Share Yes Vote") ///
	imargin(zero)			

gr export "_output/figure A25 b.pdf", replace

*******************************************************************************
* End
*******************************************************************************
